package com.duowei.diandan.app;

import org.joda.time.LocalDateTime;

/**
 * Sql Server 时间
 */
public class SqlServerDateTime {
    public static final String SQL = "select current_timestamp as ct|";

    private static SqlServerDateTime INSTANCE;

    private LocalDateTime serverDateTime = new LocalDateTime();
    private LocalDateTime startDateTime = new LocalDateTime();

    private SqlServerDateTime() {
    }

    public static SqlServerDateTime getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new SqlServerDateTime();
        }

        return INSTANCE;
    }

    public void setServerDateTime(LocalDateTime dateTime) {
        serverDateTime = dateTime;
    }

    public LocalDateTime getNowServerDateTime() {
//        return serverDateTime.plusSeconds(
//                Seconds.secondsBetween(startDateTime, new LocalDateTime())
//                        .getSeconds());
        return new LocalDateTime();
    }

    /**
     * @return yyyy-MM-dd HH:mm:ss
     */
    public String getNowServerDateTimeStr() {
        return getNowServerDateTime().toString("yyyy-MM-dd HH:mm:ss");
    }

    /**
     * 使用的地方 Wmldbjb-WMDBH
     * Wmlsb  -tcbh
     *
     * @return yyyyMMddHHmmssSSS
     */
    public String getyyyyMMddHHmmssSSSStr() {
        return getNowServerDateTime().toString("yyyyMMddHHmmssSSS");
    }

    /**
     * 使用的地方 sql server prk
     *
     * @return yyyyMMdd
     */
    public String getyyyyMMddStr() {
        return getNowServerDateTime().toString("yyyyMMdd");
    }
}
